﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WatiN.Core;

namespace WatiN.Sharepoint.Pages
{
    public abstract class BaseSPPage : Page
    {
        public BaseSPPage() : base()
        { }

        public virtual void GoTo(Browser browser, string pageUrl)
        {
            GoTo(browser, pageUrl, null);
        }

        public virtual void GoTo(Browser browser, string pageUrl, Dictionary<string, string> parameters) 
        {
            if (parameters != null)
            {
                foreach (var parameter in parameters)
                {
                    if (pageUrl.Contains('?'))
                    {
                        pageUrl += string.Format("&{0}={1}", parameter.Key, parameter.Value);
                    }
                    else
                    {
                        pageUrl += string.Format("?{0}={1}", parameter.Key, parameter.Value);
                    }
                }
            }
            browser.GoTo(pageUrl);
        }
    }
}
